import os
import json
root_dir = os.path.abspath('.')
image_dir=root_dir+"/image" 

class Item(object):
	type=""
	name=""
	url=""
	def toString(self):
		return '{"type":'+type+'","name":'+name+',"url":'+url+'}'
	def keys(self):
		return ('name', 'type','url')

	def __getitem__(self, item):
		return getattr(self, item)

def createJson():
		list=[]
		for file in os.listdir(image_dir):
			item=Item()
			itemdict= dict(item)
			itemdict["url"]="https://gitee.com/follow_the_cool_wind/Avatar/raw/master/image/"+file
			list.append(itemdict)
		return list
def get_json(path):
	file = open(path, encoding='utf8')
	file_lines = file.read()
	file.close()
	file_json = json.loads(file_lines)
	json_txt = createJson()
	for item in json_txt:
		file_json.append(item)
	with open('item.json', 'w', encoding='utf-8') as file1:
		json.dump(file_json, file1, ensure_ascii=False) 
		return

if __name__ == "__main__":
    path = root_dir+"/item.json"
    print(path) 
    get_json(path)
